package cn.stephen.study.demoproject.service.impl;

import cn.stephen.study.demoproject.dao.dbone.ReportMapper;
import cn.stephen.study.demoproject.entity.Report;
import cn.stephen.study.demoproject.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Override
    public List<Report> findAllByValue(Integer type, String startTime, String endTime) {
        if (type == null) {
            if (startTime != null && !startTime.equals("")) {
                startTime = startTime + " 00:00:00";
            }
            if (endTime != null && !endTime.equals("")) {
                endTime = endTime + " 23:59:59";
            }
        } else if (type == 0) {
            type = null;
            startTime = null;
        } else {
            startTime = null;
        }
        return reportMapper.findAllByValue(type, startTime, endTime);
    }

    @Override
    public String findById(String id) {
        return reportMapper.findById(id);
    }
}
